package com.scedu.domain;

import com.fasterxml.jackson.annotation.JsonIgnore;
import lombok.Data;
import org.springframework.security.core.GrantedAuthority;
import org.springframework.security.core.userdetails.UserDetails;

import java.util.Collection;
import java.util.List;

@Data
//直接实现UserDeails
public class SysUser implements UserDetails {
    private Integer id;
    private String username;
    private String password;
    private Integer status;
    private List<SysRole> roles; //角色列表
    @JsonIgnore
    @Override
    public Collection<? extends GrantedAuthority> getAuthorities() {
        //获取当前用户的角色信息
        return roles;
    }
    @JsonIgnore
    @Override
    public boolean isAccountNonExpired() {
        //账户是否未过期，改为true
        return true;
    }
    @JsonIgnore
    @Override
    public boolean isAccountNonLocked() {
        //账户是否未被锁定，改为true
        return true;
    }
    @JsonIgnore
    @Override
    public boolean isCredentialsNonExpired() {
        //账户是否未过期，改为true
        return true;
    }
    @JsonIgnore
    @Override
    public boolean isEnabled() {
        //是否可用,改为true
        return true;
    }
}
